﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace MidTestLib.Data
{
    public class Encryption
    {
        #region Method
        protected bool Validate(string input, ValidateType type)
        {
            Regex reg = new Regex("^[a-zA-Z0-9]*$");
            if (type == ValidateType.Numeric)
                reg = new Regex("^[1-5]*$");
            if (reg.IsMatch(input))
            {
                return true;
            }
            return false;
        }

        protected char Increment(char c)
        {
            char temp = c;
            switch (c)
            { 
                case 'z':
                    temp = 'a';
                    break;
                case 'Z':
                    temp = 'A';
                    break;
                case '9':
                    temp = '0';
                    break;
                default:
                    temp++;
                    break;
            }
            return temp;
        }

        protected char Decrement(char c)
        {
            char temp = c;
            switch (c)
            {
                case 'a':
                    temp = 'z';
                    break;
                case 'A':
                    temp = 'Z';
                    break;
                case '0':
                    temp = '9';
                    break;
                default:
                    temp--;
                    break;
            }
            return temp;
        }
        #endregion
    }

    public enum ValidateType { Alpha, Numeric}
}
